<?php
class Zend_View_Helper_Sidebar extends Zend_View_Helper_Abstract
{
	public function sidebar($type = null)
	{
		$html  = '';
		if( $type == 'carrossel' )
		{
			$html .= '<aside id="sidebar" class="carrossel-home">';
			$html .= '<ul class="steps">';
			$html .= '	<li style="background: url('.__ROOT__.'public/uploads/banner-pattern.gif) repeat-x;">';
			$html .= '		<a href="#" class="imgs"><img src="'.__ROOT__.'public/uploads/banner.png" ></a>';
			$html .= '	</li>';
			$html .= '	<li style="background: url('.__ROOT__.'public/uploads/banner-pattern2.jpg) repeat-x;">';
			$html .= '		<a href="#" class="imgs"><img src="'.__ROOT__.'public/uploads/banner2.jpg" ></a>';
			$html .= '	</li>';
			$html .= '	<li style="background: url('.__ROOT__.'public/uploads/banner-pattern3.jpg) repeat-x;">';
			$html .= '		<a href="#" class="imgs"><img src="'.__ROOT__.'public/uploads/banner3.jpg" ></a>';
			$html .= '	</li>';
			$html .= '	<li style="background: url('.__ROOT__.'public/uploads/banner-pattern4.jpg) repeat-x;">';
			$html .= '		<a href="#" class="imgs"><img src="'.__ROOT__.'public/uploads/banner4.jpg" ></a>';
			$html .= '	</li>';
			$html .= '</ul>';
			$html .= '<ul class="naveg">';
			$html .= '	<li>';
			$html .= '		<span class="active">1</span>';
			$html .= '		<span>2</span>';
			$html .= '		<span>3</span>';
			$html .= '		<span>4</span>';
			$html .= '	</li>';
			$html .= '</ul>';
			$html .= '</aside>';
		}
		if( $type == 'searchBar' )
		{
			include_once 'DataForm/DataForm.php';
			$request = Zend_Controller_Front::getInstance();
			$params = $request->getRequest()->getParams();
			
			$gender = new Application_Model_Db_Gender();
			$gender = $gender->fetchAll(null, 'order ASC');
			
			$form = new DataForm( 'form-search' );
			$form->title('Filtrar:');
			$form->form()->action = __LINKS__ . 'produtos/';
			$form->add( new Select( 'flagOptions', null, $this->flagOptions() ) );
			$form->add( new Select( 'themeOptions', null, $this->themeOptions() ) );
			
			$html .= '<aside id="sidebar" class="seachBar">';
			$html .= '	<div class="wrapper">';
			$html .= '		<ul class="filters marie">';
			$html .= '			<li><a class="filterAll" href="' . __LINKS__ . 'produtos/' . $params['id'] . '/todos' . '">Todos</a></li>';
			foreach ($gender as $value)
				$html .= '			<li><a href="' . __LINKS__ . 'produtos/' . $params['id'] . '/' . strtolower( $value->name ) . '">'.$value->name.'</a></li>';
			$html .= '		</ul>';
			$html .= '		<div class="wrapper-form">';
			$html .= 			$form->get();
			$html .= '		</div>';
			$html .= '	</div>';
			$html .= '</aside>';
		}
			
		return $html;		
	}
	
	private function flagOptions()
	{
		$tb = new Application_Model_Db_Flags();
		$data = $tb->fetchAll(null, 'order ASC');
		
		$result['0'] = 'Todos os Tipos';
		foreach ($data as $value) $result[$value->idFlag] = $value->name;
	
		return $result;
	}
	
	private function themeOptions()
	{
		$tb = new Application_Model_Db_Theme();
		$data = $tb->fetchAll('active = 1', 'order ASC');
		
		$result['0'] = 'Todos os Temas';
		foreach ($data as $value) $result[$value->name] = $value->name;
	
		return $result;
	}
}
	